<!--  Ofri Keidar 302933981 group 05 -->

<%@page import="model.database.DBException"%>
<%@page import="controller.CommonValues"%>
<%@page import="view.WebCommons"%>
<%@page import="controller.ManagerController"%>
<%@page import="java.util.List" %>
<%@page import="java.util.Map" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="../../style/myTemplate/style.css"
	type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>All employees</title>
</head>
<body>

	<span class="customHeader2">All employees in store</span>

	<%
		try {
				
			// extract controller from session
			ManagerController controller = (ManagerController) session.getAttribute(WebCommons.CONTROLLER);
			
			// try getting details of all employees
			List<Map<String,String>> employeesDetails = controller.getEmployees();
	%>

	<div id="page" style="width: auto;">
		<div class="post">
			<div id="sidebar" style="width: auto;">	
				<table border=2>
					<%
					// column names
					%>
					<tr>
						<td><span class="customMenuOption">Number</span></td>
						<td><span class="customMenuOption">Name</span></td>
						<td><span class="customMenuOption">Username</span></td>
					</tr>
					<%
					// display data
					int numOfEmployees = employeesDetails.size();
					for (int i = 0; i < numOfEmployees; i++) {
			
						// display details of current employee
						Map<String, String> currEmployeeDetails = employeesDetails.get(i);				
						%>
						<tr>
							<td style="text-align: center;"><span class="customFormValue"><%=currEmployeeDetails.get(CommonValues.NUMBER)%></span></td>
							<td><span class="customFormValue"><%=currEmployeeDetails.get(CommonValues.NAME)%></span></td>
							<td><span class="customFormValue"><%=currEmployeeDetails.get(CommonValues.USER_NAME)%></span></td>
						</tr>
						<%
					}
						%>
				</table>
			</div>
		</div>
	</div>
	<%		
		
		} catch (DBException e) {
			
			// move to error page
			response.sendRedirect("../../commonPages/ErrorPage.jsp");
		}
		
	// return to main menu
	String menuPage = (String) session.getAttribute(WebCommons.MAIN_MANU);
	%>
	<div id="footer">
		<span class="myLink"><A HREF="<%="../../menus/" + menuPage%>">Back
				to Menu</A></span>
	</div>

</body>
</html>